<?php
/**
 * Created by JetBrains PhpStorm.
 * User: scala
 * Date: 12-10-27
 * Time: 上午12:44
 * To change this template use File | Settings | File Templates.
 */
class NewsModel extends Model
{
    protected $_validate=array(
        array('newstype','require','没有选择信息类型！'),
        array('newstype','checkNewsType','！请选择信息类型',Model::MUST_VALIDATE,"callback",Model::MODEL_BOTH),
        array('title','require','请输入文章标题！'),
        array('newsindex','require','请输入文章索引！'),
        array('content','require','请输入正文！'),
    );


    function checkNewsType($data){
        if(trim($data)==-1){
            return false;
        }else{
            return true;
        }
    }


    protected $_auto=array(
        array("createtime","time",Model::MODEL_INSERT,"function"),
        array("author","genAuthor",Model::MODEL_BOTH,"callback"),
        array("clicktimes","0"),
    );


    function genAuthor(){
        import("ORG.Util.Session");
        if(Session::is_set(C("USER_AUTH_KEY"))){
            return Session::get(C("USER_AUTH_KEY"));
        }else{
            return 0;
        }
    }
}
